From : Steve Flock (xbones@cet.com)
Subject : PowerPacker decrunching routines
I've had a couple of requests for these.. So I touched them up a little
bit and am including them here. If anyone has problems with them, let me
know and I'll try to help.
Function calcpp{name$}
;
; This function Calculates the filesize of a powerpacked module
;
size.l=-1
If OpenFile(0,name$) ; Attempt to open the file.
FileInput 0 ;
FileSeek 0,(Lof(0))-4 ; Search down until we can get the packed size.
nb.l=Cvl(Inkey$(4)) ; Read in
size.l=(nb.l LSR 8) ; We now have the calculated size
PopInput ;
CloseFile 0 ; Finish up
EndIf
Function Return size.l ; Return the size
End Statement
Statement loadpp{filename$}
If Exists(filename$) ; Valid file?
size.l=calcpp{filename$} ; Calculate the size
If OpenFile(0,filename$) ; Open it
FileInput 0 ;
FileSeek 0,0 ;
c.l=Lof(0) ; Size to read in
If Reserve(1,c.l+10)=0 Then End ; Reserve some memory
ReadMem 0,Start(1),c.l ; Read it in
PopInput:CloseFile 0 ; Close up shop
If Reserve(0,size.l+10,%10)=0 Then End ; Reserve amount needed for depack'd file
a.l=Start(1) ;
b.l=a.l+(c.l) ;
PPDecrunch a.l,b.l,Start(0) ; Decrunch
Erase 1 ;
Else ;
End ; Quit if unsuccessful
EndIf
EndIf
End Statement